home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / fdate25a.zip / FDATE.DOC next >
Text File  |  1991-11-14  |  31KB  |  852 lines

  1. FDATE      Version 2.5a                          Nov 13, 1991
  2. ===================================================================
  3. FDATE: a utility for date manipulation in batch files.
  4. ===================================================================
  5. Stephen Ferg             5113 N. 8th Road, Arlington, VA 22205-1201
  6. Voice (703) 525-22541    CompuServe 73377,1157
  7.  
  8. ===================================================================
  9. Format: FDATE /Ffunc /Nnum /Adate /Bdate /Iformat /Oformat /Pstring
  10. ===================================================================
  11.  
  12.  
  13. FDATE PARAMTERS
  14. ===============
  15.  
  16. The parameters that are required depend on the function requested.
  17. Parameters that are specified, but not needed, are ignored.
  18. Executing FDATE without any parameters displays a brief help screen.
  19.  
  20. Parameters can be in any order and upper or lower case.
  21.      Note that although format specifications are not case sensitive,
  22.      they ARE "text sensitive".  If any characters are missing,
  23.      added, or mistyped, the format specification will be rejected.
  24.      (A common mistake is to enter "/format" instead of "/Fformat".)
  25.  
  26.  
  27.  /F  requests a particular FDATE function
  28.      If this parameter is not specified, or is specified incorrectly,
  29.      FDATE displays a help screen.  If you unexpectedly get the help
  30.      screen displayed, you probably have omitted the /F parameter.
  31.  
  32.  /N  number of days (always a number)
  33.  /A  date A         (for math functions, a number)
  34.  /B  date B         (for math functions, a number)
  35.  
  36.  /I  specifies format of input date(s)
  37.  /O  specifies format of output date
  38.  
  39.  /L  specifies language of output.   If omitted, English is assumed.
  40.      /Leng  English-language output  [the default]
  41.      /Lfr   French-language output
  42.  
  43.  /P  specifies a prefix string for the output
  44.      This optional parameter may always be specified or omitted.
  45.      Prefix string must be enclosed in single or double quotes
  46.      EXAMPLE:  FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
  47.  
  48.  
  49. SYMBOL CONVENTIONS
  50. ==================
  51.  
  52. The following symbols are used in specifying date formats:
  53.  
  54. SYMBOL  EXAMPLE   MEANING
  55. ------  -------   -------------------------------------
  56. cc        19      century
  57. yy        85      year
  58. mm        02      month
  59. zm         2      month without leading zero
  60. dd        09      day
  61. zd         9      day   without leading zero
  62. mn       January  month name
  63. mn3      Jan      month name, first 3 characters only
  64. dow      Tuesday  day of week
  65. dow3     Tue      day of week, first 3 characters only
  66. dow#      3       day of week as a number (Sunday=1, Monday = 2, etc.)
  67. today             is a "pseudodate" representing the current date
  68.  
  69.  
  70. PSEUDODATES
  71. ===========
  72.  
  73. today     can be used with either /A or /B, e.g. /Atoday.
  74.  
  75. EXAMPLE
  76.           rem Get the date that is 90 days from today
  77.           FDATE /Fadd /N90 /Atoday /Omm-dd-ccyy
  78.  
  79.           rem determine if this year is a leapyear
  80.           FDATE /Fformat /Atoday /Oleapyr
  81.  
  82.  
  83.  
  84. INPUT FORMATS
  85. =============
  86.  
  87. FORMAT      EXAMPLES      DISCUSSION
  88. ------      ---------     -----------------------------
  89. ccyymmdd    19862002
  90.  
  91. mm-dd-ccyy  02-20-1986    In an input format specification, the dash
  92.             02/20/1986    symbols represent ANY non-numeric symbol.
  93.              2/20/1986    Leading zeros need not be present.
  94.  
  95. mm-dd-yy    02-20-86      In this input format,
  96.             02/20/86      cc = 19 (century = 19) is assumed
  97.  
  98. NOTE
  99. If "today" is the ONLY date specified, it is not
  100. necessary to specify an input format using /I.
  101.  
  102.  
  103. OUTPUT FORMATS
  104. ==============
  105.  
  106. FORMAT        EXAMPLES      DISCUSSION
  107. ------        ---------     -----------------------------
  108. ccyymmdd      19860220
  109.   yymmdd        860220
  110.     mmdd          0220
  111. ccyymm        198602
  112.  
  113. In the following formats, months precede days (American style)
  114. ------------------------------------------------------------------
  115. mm/dd/ccyy    02/20/1986
  116. mm-dd-ccyy    02-20-1986
  117. zm/zd/ccyy     2/20/1986    no leading zeros in day or month
  118. zm-zd-ccyy     2-20-1986    no leading zeros in day or month
  119. mm/dd/yy      02/20/86
  120. mm-dd-yy      02-20-86
  121. zm/zd/yy       2/20/86      no leading zeros in day or month
  122. zm-zd-yy       2-20-86      no leading zeros in day or month
  123.  
  124. In the following formats, days precede months  (European style)
  125. ------------------------------------------------------------------
  126. mm/dd/ccyy    02/20/1986
  127. mm-dd-ccyy    02-20-1986
  128. zm/zd/ccyy     2/20/1986    no leading zeros in day or month
  129. zm-zd-ccyy     2-20-1986    no leading zeros in day or month
  130. mm/dd/yy      02/20/86
  131. mm-dd-yy      02-20-86
  132. zm/zd/yy       2/20/86      no leading zeros in day or month
  133. zm-zd-yy       2-20-86      no leading zeros in day or month
  134.  
  135. ------------------------------------------------------------------
  136.  
  137. dow#           5            Sunday=1, Monday=2 .... Saturday=7.
  138.  
  139. dow            Thursday     name of day of week
  140.                Jeudi        if /Lfr specified
  141.  
  142. dow3           Thu          first 3 characters of name of day of week
  143.                Jeu          if /Lfr specified
  144.  
  145. ------------------------------------------------------------------
  146.  
  147. leapyr          0           0 if year is a leapyear, otherwise 1.
  148.                                ------------------------------------
  149.                                365 + this number gives total
  150.                                      number of days in the year.
  151.                                 28 + this number gives total
  152.                                      number of days in February.
  153.                                ------------------------------------
  154.  
  155.  
  156. full         12:24pm on Saturday, February 5, 1992
  157.              12:24pm Samedi, le 5 Fevrier 1992    [/Lfr specified]
  158. -----------------------------------------------------------------------
  159. NOTE that the following formats contain embedded spaces.  Consequently
  160. they must be enclosed in double quotes. EXAMPLE: /O"mn zd, ccyy".
  161. -----------------------------------------------------------------------
  162. "zd mn ccyy"      5 February 1992
  163. "zd mn, ccyy"     5 February, 1992
  164. "mn3 dd ccyy"     Feb 05 1992
  165. "mn3 dd, ccyy"    Feb 05, 1992
  166. "mn zd, ccyy"     February 5, 1992
  167.  
  168.  
  169.  
  170. "JULIAN" OUTPUT FORMATS
  171. =======================
  172.  
  173. FORMAT        EXAMPLES      DISCUSSION
  174. ------        ---------     -----------------------------
  175.  
  176. juldate           311       BUSINESS "Julian date" expressed as number
  177.                             of days since January 1 of the same year.
  178.  
  179. day#           727198       TRUE "Julian date" expressed as number
  180.                             of days since January 1, 0001.
  181.  
  182. minute#         33088       "Julian minutes": time expressed as number
  183.                             of minutes  since midnight, January 1, 1990.
  184.  
  185. second#        633088       "Julian seconds": time expressed as number
  186.                             of seconds  since midnight, January 1, 1990.
  187.  
  188. ----------------------------------------------------------------------
  189.    Running FDATE with /O parameter for a "Julian time" produces a
  190.    number based on the current time of day and the date in the /A parm.
  191.  
  192.    If, on January 10, 1992 at 2 pm, you run FDATE this way:
  193.        FDATE /Fformat /Atoday /Ominute#
  194.    it will produce the Julian minute for January 10, 1992 at 2 pm.
  195.  
  196.    If, on January 10, 1992 at 2 pm, you run FDATE this way:
  197.        FDATE /Fformat /A01-15-1992 /Imm-dd-ccyy  /Ominute#
  198.    it will produce the Julian minute for January 15, 1992 at 2 pm.
  199. ----------------------------------------------------------------------
  200.  
  201. DATE FUNCTIONS
  202. ==============
  203.  
  204. FUNCTION  FDATE /Ffunc /Adate /Iformat /Oformat
  205. --------  -------------------------------------------
  206. /Fformat  returns /Adate in format specified by /Oformat
  207.           Since /Aformat and /Oformat can be different, the FORMAT
  208.           function is used change a date from one format to another.
  209.           Because of the wide variety of output formats, the FORMAT
  210.           function can also be used to determine the day of week of the
  211.           date, whether the date is in a normal or leap year, etc.
  212. EXAMPLES
  213.           FDATE /Fformat /A19920101 /Iccyymmdd /O"mn zd, ccyy"
  214.           FDATE /Fformat /Atoday               /Odow
  215.  
  216.  
  217. FUNCTION  FDATE /Ffunc /Nnumdays /Adate /Iformat /Oformat
  218. --------  -------------------------------------------
  219. /Fadd     Adds      /Ndays to   /Adate, produces date in /Oformat format
  220. /Fsub     Subtracts /Ndays from /Adate, produces date in /Oformat format
  221.  
  222. EXAMPLES
  223.           FDATE /Fadd /N90 /A01-01-1992 /Imm-dd-ccyy /Omm-dd-ccyy
  224.           FDATE /Fsub /N90 /A01-01-1992 /Imm-dd-ccyy /Omm-dd-ccyy
  225.           FDATE /Fadd /N90 /Atoday                   /Omm-dd-ccyy
  226.  
  227.  
  228. FUNCTION  FDATE /Ffunc /Adate /Bdate /Iformat
  229. --------  -------------------------------------------
  230. /Fdif     Returns number of days between /Adate and /Bdate
  231.           Order of the two dates is not significant.
  232.           Note that for DIF, both dates must be in the SAME
  233.           format, the input format specified in /Iformat.
  234.           If the two dates are not in the same format, reformat one
  235.           of the dates using the /Fformat function and
  236.           a utility like STRINGS or GET.  See EXAMPLE #2, below.
  237.  
  238. EXAMPLES
  239.           FDATE /Fdif /A01-01-1992 /B11-11-1992  /Imm-dd-ccyy
  240.           FDATE /Fdif /A11-11-1992 /B01-01-1992  /Imm-dd-ccyy
  241.           FDATE /Fdif /Atoday      /B01-01-1992  /Imm-dd-ccyy
  242.  
  243.  
  244. MATH FUNCTIONS
  245. ==============
  246.  
  247. FUNCTION  FDATE /Ffunc /Anum  /Bnum
  248. --------  -------------------------------------------
  249. /F#dif    returns the difference between the integers specified
  250.           on the /A and /B parms.  Can be used to calculate the
  251.           number of minutes(seconds, days) between two
  252.           "Julian"  minutes(seconds, dates).
  253.  
  254. /F#add    returns the sum of the integers specified
  255.           on the /A and /B parms.  Can be used to calculate the
  256.           "Julian" minute(second, date) in the future from a given
  257.           "Julian" minute(second, date).
  258.  
  259. /F#comp   compares the integers specified on the /A and /B parms.
  260.           returns         when
  261.             LT            /A  is less    than /B
  262.             EQ            /A  is equal   to   /B
  263.             GT            /A  is greater than /B
  264.  
  265.           See Example 3.
  266.  
  267. PUTTING FDATE OUTPUT INTO AN ENVIRONMENT VARIABLE
  268. =================================================
  269.  
  270. FDATE's output is written to standard output, that is, it is displayed
  271. on the screen.  Output can be redirected to a file, or it can piped to
  272. a utility (such as STRINGS or GET) that will put it into an
  273. environment variable.
  274.  
  275. Manipulating the environment is an incredibly tricky business.  There
  276. are questions of the local versus master environment, the version of
  277. DOS you are running, and the environment under which you are running
  278. (DOS, Windows, Carousel).  In order to keep FDATE focussed on
  279. date-related issues, I have not attempted to make it put its output
  280. directly into an environment variable.
  281.  
  282. One way to put FDATE's output into an environment variable is to use
  283. the /P (prefix string) feature to create a DOS "SET" statement,
  284. redirect the output to a batch file, and CALL the batch file.
  285.  
  286.   FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
  287.   call JUNKTEMP.BAT
  288.   del  JUNKTEMP.BAT
  289.  
  290. There are also shareware and public domain utilities that are written
  291. specifically to manipulate environment variables, and do that job very
  292. well.  FDATE's output can be put into an environment variable by
  293. piping it to one of these utilities.  When piping FDATE output to a
  294. utility, redirecting the output to NUL will you can prevent the output
  295. being ECHOed to the screen.
  296.  
  297.    EXAMPLE: using STRINGS to put date into DATE1 environment variable
  298.    FDATE /Fformat /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
  299.  
  300.    -----------------------------------------------------------------
  301.    I recommend Bob Stephan's GET and PC Magazine's STRINGS.
  302.    As of November 5, 1991, the current version of GET is GET24.ZIP.
  303.    On CompuServe, use IBMFF to look for GET*.ZIP in CIS:IBMSYS
  304.    GET is also available from the Public Software Library in Houston.
  305.    On CompuServe, look for STRING.ZIP in Utilities Lib of ZNT:UTILFORUM
  306.    -----------------------------------------------------------------
  307.  
  308. =======================================================================
  309. EXAMPLE #1
  310. Redirect FDATE output to a file, or to a callable batch file,
  311. or pipe it to STRINGS or GET to store it in an environment variable
  312. =======================================================================
  313. FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
  314.  
  315. FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is " >FDATE.OUT
  316.  
  317. FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET DATE1=" >JUNKTEMP.BAT
  318. call JUNKTEMP.BAT
  319. del  JUNKTEMP.BAT
  320.  
  321. rem use STRINGS to put date into DATE1 environment variable
  322. FDATE /Fformat /Atoday /O"mn zd, ccyy" |STRINGS date1= ASK >NUL
  323.  
  324. rem use GET (ver 2.3+) to put date into DATE1 environment variable
  325. FDATE /Fformat /Atoday /O"mn zd, ccyy" |GET ZE /Vdate1 >NUL
  326.  
  327.  
  328.  
  329. =======================================================================
  330. EXAMPLE #2
  331. Find the difference (in days) between two dates in different formats
  332. Use GET to put FDATE output into environment variables.
  333. =======================================================================
  334. set date1=05-10-1992
  335.  
  336. rem reformat date literal into same format as date1
  337. FDATE /Fformat /Imm-dd-yy   /A05-08-92 /Omm-dd-ccyy | GET ZE /Vdate2>NUL
  338.  
  339. rem get difference between date1 and date2
  340. FDATE /Fdif /Imm-dd-ccyy /A%date1%  /B%date2%| GET ZE /vdiff>NUL
  341.  
  342. echo The difference is %diff% days.
  343.  
  344.  
  345.  
  346. =======================================================================
  347. EXAMPLE #3
  348. Schedule a program to run at a specified time in the future.  Note that
  349. this involves a lot of disk activity because DOS re-reads the batch
  350. file from disk every time it does a GOTO LOOPTOP.  If you do this, it
  351. is probably a good idea to run the batch file from a RAM DISK.
  352. =======================================================================
  353. REM GET CURRENT JULIAN MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
  354. FDATE /Fformat /Atoday /Ominute#  |STRINGS RunTime= ASK >NUL
  355.  
  356. REM ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
  357. FDATE /F#add   /A%RunTime% /B120 |STRINGS RunTime= ASK >NUL
  358.  
  359. REM LOOP UNTIL NOWTIME HAS REACHED RUNTIME
  360. :LoopTop
  361.   FDATE /Fformat /Atoday     /Ominute#   |STRINGS NowTime=  ASK >NUL
  362.   FDATE /F#comp  /A%NowTime% /B%RunTime% |STRINGS TimeComp= ASK >NUL
  363.   if (%TimeComp%)==(LT) goto loopTOP
  364. :LoopEnd
  365.  
  366. echo STARTING EXECUTION OF APPLICATION: XXXXX
  367.  
  368.  
  369.  
  370. =======================================================================
  371. EXAMPLE #4
  372. Rename file BACKUP.LOG to a name that contains today's date
  373. =======================================================================
  374. FDATE /Fformat /Atoday /Oyymmdd /P"@SET DATE1=" >JUNKTEMP.BAT
  375. call JUNKTEMP.BAT
  376. del  JUNKTEMP.BAT
  377. ren  BACKUP.LOG  BK%DATE1%.LOG
  378. SET  DATE1=
  379.  
  380. FDATE'S ALGORITHMS
  381. ==================
  382.  
  383.  
  384. FDATE IS DESIGNED FOR BUSINESS, NOT HISTORICAL, APPLICATIONS
  385. ============================================================
  386. FDATE is intended for business applications, not historical ones.
  387. As far as FDATE is concerned, the calendar has followed the same
  388. pattern, unchanged, since January 1, 0001.
  389.     -------------------------------------------------------------------
  390.     FDATE does not take into account historical changes in the calendar
  391.     such as the glitch in English dates that occurred when Britain
  392.     moved from the Julian to Gregorian calendar in the 18th century,
  393.     or Russia made the same move in the early 20th century.
  394.     -------------------------------------------------------------------
  395.  
  396.  
  397. FDATE'S BASE DATE
  398. =================
  399.     Internally, date manipulations are based on translating a calendar
  400.     date into an "absolute" or "TRUE Julian" date:  a date expressed
  401.     as the number of days from some day in the distant past.
  402.     FDATE's base date is January 1, 0001 (i.e. day 1 of month 1 of year 1)
  403.     FDATE's absolute date for January 1, 0001 is      1.
  404.     FDATE's absolute date for January 1, 1992 is 727198.
  405.  
  406.  
  407. FDATE'S LEAP YEAR ALGORITHM
  408. ===========================
  409.     Every year evenly divisible by 4 IS a leap year
  410.       EXCEPT THAT
  411.         Every year evenly divisible by 100 IS NOT a leap year
  412.           EXCEPT THAT
  413.             Every year evenly divisible by 400 IS a leap year
  414.     .
  415.     Using this algorithm
  416.          1983  is not a leap year
  417.          1984  is     a leap year
  418.          1900  is not a leap year
  419.          2000  is     a leap year
  420.  
  421.     See "A Machine Algorithm for Processing Calendar Dates", by
  422.          Henry F. Fliegel       (Georgetown University Observatory)
  423.          Thomas C. Van Flandern (U.S. Naval Observatory)
  424.          COMMUNICATIONS OF THE ACM, Volume 11, Number 10, October 1968
  425.  
  426. There is supposedly a new adjustment to the leapyear algorithm,
  427. which specifies the additional exception:
  428.  
  429.               EXCEPT THAT
  430.                 Every year evenly divisible by 4000 IS a leap year
  431.  
  432. See "Bit By Bit" column, COMPUTER LANGUAGE, November 1989, p.  148.
  433. This adjustment is not part of FDATE's leapyear algorithm.
  434. Unless your application is working with dates 2,000 years in the
  435. future, the lack of this exception will be irrelevant for you.
  436.  
  437. USE AND DISTRIBUTION OF FDATE
  438. =============================
  439.  
  440. FDATE is freeware.  Although the author retains the copyright, FDATE
  441. can be copied, used, and distributed freely as long as both FDATE and
  442. its DOC file are not altered and are distributed together.
  443.  
  444. FDATE can be included in shareware packages as long as both FDATE and
  445. its DOC file are included in the shareware package.
  446.  
  447. If you have received FDATE as part of some larger shareware package,
  448. please be aware that you may freely use, copy, and distribute FDATE
  449. without paying a fee for, or registering, the package.
  450.  
  451. The author explicitly disavows any claim whatsoever about the
  452. functionality of the software, and disclaims liability for anything and
  453. everything bad that might happen in connection with, before, during, or
  454. after using it.  I have tried to make FDATE work right, but everybody
  455. makes mistakes, so you use FDATE at your own risk.
  456.  
  457. I don't know if people will find FDATE useful, and I'd like to find
  458. out.  If you find FDATE useful and use it on a regular basis, I'd
  459. appreciate it if you would drop me a short note via US mail or
  460. CompuServe, telling me about how you are using FDATE.
  461.  
  462. If you need other input/output formats, or if you need a different
  463. leapyear algorithm, please contact the author.
  464.  
  465.  
  466. FDATE REVISION HISTORY
  467. ======================
  468.  
  469. Letters appended to version numbers indicate modifications to
  470. the DOC file, without any modification to the software.
  471.  
  472. 1.1   Oct 01, 1991
  473.       First version
  474.  
  475. 1.2   Oct 15, 1991
  476.       Replaced shareware date routines with Ferg routines
  477.       NOTE THAT THERE IS NOT MUCH ERROR-CHECKING IN THIS VERSION.
  478.  
  479. 1.2d  Oct 16, 1991
  480.       Minor changes to show redirection and piping of FDATE output
  481.       Revised discussion of how FDATE may be distributed.
  482.       Added note on business-related, non-historical purpose of FDATE
  483.       Added note on 4000-year leap-year exception
  484.  
  485. 1.2e  Oct 17, 1991
  486.       Added note on why FDATE doesn't directly set an Env variable
  487.  
  488. 2.0a  Nov 05, 1991
  489.       Modified Help display to show parameters and their meanings
  490.       Added output format YYMMDD
  491.       Added output format minute# and second#
  492.       Added function #dif
  493.       Added test of GET and STRINGS      to test batch file.
  494.       Added test of minute# and second#  to test batch file.
  495.  
  496.  
  497. 2.1a  Nov 06, 1991
  498.       Added /P parameter and modified documentation accordingly
  499.       Added JULDATE output format
  500.       Minor changes and reformatting to documenation
  501.  
  502. 2.2a  Nov 08, 1991
  503.       Added example #4, showing how to put current date in a filename
  504.       Added MMDD output formats
  505.  
  506. 2.3a  Nov 09, 1991
  507.       Added /L (language parameter) to allow French-language output
  508.       Added the following output formats
  509.          full
  510.          "mn3 zd, ccyy"
  511.          "zd mn, ccyy"
  512.          "zd mn ccyy"
  513.          European-style date formats
  514.                in which day occurs before month (e.g. dd/mm/ccyy)
  515.  
  516. 2.4a  Nov 10, 1991
  517.       Fixed display of time in /Ofull so that a minutes value of
  518.             less than 10 would display with a leading zero:
  519.             e.g. "10:08 am" instead of "10:8 am".
  520.  
  521. 2.5a  Nov 13, 1991
  522.       Added output format CCYYMM
  523.  
  524. ======================================================================
  525. The following batch file can be used to test FDATE, and illustrates
  526. the way it is used.
  527. ======================================================================
  528. @ECHO OFF
  529. BREAK ON
  530. CLS
  531. ECHO TEST HELP SCREEN
  532. FDATE
  533. @PAUSE
  534. ECHO ON
  535.  
  536. CLS
  537. @echo TEST PREFIX STRING FUNCTIONS
  538. FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"Today is "
  539.  
  540. set  FDATE=
  541. FDATE /Fformat /Atoday /O"mn zd, ccyy" /P"@SET FDATE=" >JUNKTEMP.BAT
  542. call JUNKTEMP.BAT
  543. del  JUNKTEMP.BAT
  544. ECHO Value of FDATE environment variable is: %FDATE%
  545. set  FDATE=
  546. @PAUSE
  547.  
  548. CLS
  549. @echo TEST TODAY AND ADD, SUB FUNCTIONS
  550. FDATE /Fadd /N90 /Atoday   /Omm-dd-ccyy
  551. FDATE /Fsub /N90 /Atoday   /Omm-dd-ccyy
  552. FDATE /Fdif /Atoday      /B01-01-1990 /Imm-dd-ccyy /Omm-dd-ccyy
  553. FDATE /Fdif /A01-01-1990 /Btoday      /Imm-dd-ccyy /Omm-dd-ccyy
  554. FDATE /Fdif /Atoday      /Btoday                   /Omm-dd-ccyy
  555. @PAUSE
  556.  
  557. CLS
  558. @echo TEST DIF
  559. FDATE /Fdif /A12-31-0008 /B01-01-0009 /Imm-dd-ccyy /Omm-dd-ccyy
  560. FDATE /Fdif /Iccyymmdd /A19801230 /B19801231
  561. FDATE /Fdif /Iccyymmdd /A19801230 /B19801220
  562. @PAUSE
  563.  
  564. CLS
  565. @echo TEST DIF
  566. FDATE /Fdif /Iccyymmdd /A19800101 /B19801231
  567. FDATE /Fdif /Iccyymmdd /A19810101 /B19811231
  568. FDATE /Fdif /Iccyymmdd /A20000101 /B20001231
  569. FDATE /Fdif /Iccyymmdd /A19000101 /B19001231
  570. FDATE /Fdif /Iccyymmdd /A16000101 /B16001231
  571. @PAUSE
  572.  
  573. CLS
  574. @echo TEST SUB
  575. FDATE /Fsub /N1 /A12-31-0008 /Imm-dd-ccyy /Omm-dd-ccyy
  576. FDATE /Fsub /N1 /Atoday                   /Omm-dd-ccyy
  577. @PAUSE
  578.  
  579. CLS
  580. @echo TEST ADD
  581. FDATE /Fadd /N1 /A12-31-0008 /Imm-dd-ccyy /Omm-dd-ccyy
  582. FDATE /Fadd /N1 /Atoday                   /Omm-dd-ccyy
  583. @PAUSE
  584.  
  585. CLS
  586. @echo TEST ADD ACROSS LEAP YEAR BOUNDARIES
  587. FDATE /Fadd /N1 /A12-31-0003 /Imm-dd-ccyy /Omm-dd-ccyy
  588. FDATE /Fadd /N1 /A12-31-0099 /Imm-dd-ccyy /Omm-dd-ccyy
  589. FDATE /Fadd /N1 /A12-31-0399 /Imm-dd-ccyy /Omm-dd-ccyy
  590. FDATE /Fadd /N1 /A12-31-1899 /Imm-dd-ccyy /Omm-dd-ccyy
  591. FDATE /Fadd /N1 /A12-31-1999 /Imm-dd-ccyy /Omm-dd-ccyy
  592. @PAUSE
  593.  
  594. CLS
  595. FDATE /Fadd /N1 /A12-31-0004 /Imm-dd-ccyy /Omm-dd-ccyy
  596. FDATE /Fadd /N1 /A12-31-0100 /Imm-dd-ccyy /Omm-dd-ccyy
  597. FDATE /Fadd /N1 /A12-31-0400 /Imm-dd-ccyy /Omm-dd-ccyy
  598. FDATE /Fadd /N1 /A12-31-1900 /Imm-dd-ccyy /Omm-dd-ccyy
  599. FDATE /Fadd /N1 /A12-31-2000 /Imm-dd-ccyy /Omm-dd-ccyy
  600. @PAUSE
  601.  
  602. CLS
  603. @echo TEST SUB BELOW LEAP YEAR BOUNDARIES
  604. FDATE /Fsub /N1 /A12-31-0004 /Imm-dd-ccyy /Omm-dd-ccyy
  605. FDATE /Fsub /N1 /A12-31-0100 /Imm-dd-ccyy /Omm-dd-ccyy
  606. FDATE /Fsub /N1 /A12-31-0400 /Imm-dd-ccyy /Omm-dd-ccyy
  607. FDATE /Fsub /N1 /A12-31-1900 /Imm-dd-ccyy /Omm-dd-ccyy
  608. FDATE /Fsub /N1 /A12-31-2000 /Imm-dd-ccyy /Omm-dd-ccyy
  609. @PAUSE
  610.  
  611. CLS
  612. @echo TEST SUB ACROSS LEAP YEAR BOUNDARIES
  613. FDATE /Fsub /N1 /A01-01-0004 /Imm-dd-ccyy /Omm-dd-ccyy
  614. FDATE /Fsub /N1 /A01-01-0100 /Imm-dd-ccyy /Omm-dd-ccyy
  615. FDATE /Fsub /N1 /A01-01-0400 /Imm-dd-ccyy /Omm-dd-ccyy
  616. FDATE /Fsub /N1 /A01-01-1900 /Imm-dd-ccyy /Omm-dd-ccyy
  617. FDATE /Fsub /N1 /A01-01-2000 /Imm-dd-ccyy /Omm-dd-ccyy
  618. @PAUSE
  619.  
  620. CLS
  621. @echo TEST SUB ACROSS LEAP YEAR BOUNDARIES
  622. FDATE /Fsub /N1 /A01-01-0005 /Imm-dd-ccyy /Omm-dd-ccyy
  623. FDATE /Fsub /N1 /A01-01-0101 /Imm-dd-ccyy /Omm-dd-ccyy
  624. FDATE /Fsub /N1 /A01-01-0401 /Imm-dd-ccyy /Omm-dd-ccyy
  625. FDATE /Fsub /N1 /A01-01-1901 /Imm-dd-ccyy /Omm-dd-ccyy
  626. FDATE /Fsub /N1 /A01-01-2001 /Imm-dd-ccyy /Omm-dd-ccyy
  627. @PAUSE
  628.  
  629. CLS
  630. @echo TEST OUTPUT FORMATS (#1)
  631. FDATE /Fformat /Atoday /Occyymmdd
  632. FDATE /Fformat /Atoday /Oyymmdd
  633. FDATE /Fformat /Atoday /Ommdd
  634. @PAUSE
  635.  
  636. CLS
  637. @echo TEST OUTPUT FORMATS (#2)
  638. FDATE /Fformat /Atoday /Omm-dd-ccyy
  639. FDATE /Fformat /Atoday /Ozm-zd-ccyy
  640. FDATE /Fformat /Atoday /Omm/dd/ccyy
  641. FDATE /Fformat /Atoday /Ozm/zd/ccyy
  642. @PAUSE
  643.  
  644. CLS
  645. @echo TEST OUTPUT FORMATS (#3)
  646. FDATE /Fformat /Atoday /O"mn zd, ccyy"
  647. FDATE /Fformat /Atoday /O"mn3 dd ccyy"
  648. FDATE /Fformat /Atoday /O"mn3 dd, ccyy"
  649. FDATE /fformat /atoday /Ofull /p"It is now "
  650. @PAUSE
  651.  
  652. CLS
  653. @echo TEST OUTPUT FORMATS (#4)
  654. FDATE /Fformat /Atoday /Odow#
  655. FDATE /Fformat /Atoday /Odow
  656. FDATE /Fformat /Atoday /Odow3
  657. @PAUSE
  658.  
  659.  
  660. CLS
  661. @echo TEST OUTPUT FORMATS (#3) (FRENCH)
  662. FDATE /Fformat /Atoday /O"mn zd, ccyy"   /Lfr
  663. FDATE /Fformat /Atoday /O"mn3 dd ccyy"   /Lfr
  664. FDATE /Fformat /Atoday /O"mn3 dd, ccyy"  /Lfr
  665. FDATE /fformat /atoday /Ofull /p"Maintenant il est "  /Lfr
  666. @PAUSE
  667.  
  668. CLS
  669. FDATE /Fformat /Atoday /Odow             /Lfr
  670. FDATE /Fformat /Atoday /Odow3            /Lfr
  671. FDATE /Fformat /Atoday /O"zd mn ccyy"    /Lfr
  672. FDATE /Fformat /Atoday /O"zd mn, ccyy"   /Lfr
  673. @PAUSE
  674.  
  675. CLS
  676. @echo TEST OUTPUT FORMATS (#5)
  677. FDATE /Fformat /Atoday /Oday#
  678. FDATE /Fformat /Atoday /Ominute#
  679. FDATE /Fformat /Atoday /Osecond#
  680. FDATE /Fformat /Atoday /Ojuldate
  681. FDATE /Fformat /Atoday /Oleapyr
  682. @PAUSE
  683.  
  684. CLS
  685. @echo TEST ERROR MESSAGES
  686. FDATE /Fformat /Atoday /OjuXdate
  687. FDATE /Fformat /A18880101 /Iccyymmdd /Ominute#
  688. FDATE /Fformat /A21010101 /Iccyymmdd /Ominute#
  689. @REM missing A parm
  690. FDATE /Fformat  /today /Ofull
  691. @PAUSE
  692.  
  693. CLS
  694. @echo TEST LEAPYR (#1)
  695. FDATE /Fformat /A01-01-0001  /Imm-dd-ccyy /Oleapyr
  696. FDATE /Fformat /A01-01-0004  /Imm-dd-ccyy /Oleapyr
  697. FDATE /Fformat /A01-01-0005  /Imm-dd-ccyy /Oleapyr
  698. FDATE /Fformat /A01-01-0100  /Imm-dd-ccyy /Oleapyr
  699. FDATE /Fformat /A01-01-0400  /Imm-dd-ccyy /Oleapyr
  700. FDATE /Fformat /A01-01-1600  /Imm-dd-ccyy /Oleapyr
  701. @PAUSE
  702.  
  703. CLS
  704. @echo TEST LEAPYR (#2)
  705. FDATE /Fformat /A01-01-1900  /Imm-dd-ccyy /Oleapyr
  706. FDATE /Fformat /A01-01-1984  /Imm-dd-ccyy /Oleapyr
  707. FDATE /Fformat /A01-01-1991  /Imm-dd-ccyy /Oleapyr
  708. FDATE /Fformat /A01-01-1992  /Imm-dd-ccyy /Oleapyr
  709. FDATE /Fformat /A01-01-2000  /Imm-dd-ccyy /Oleapyr
  710. @PAUSE
  711.  
  712. CLS
  713. @echo TEST ABILITY OF INPUT FORMAT TO HANDLE LEADING ZERO SUPPESSION
  714. FDATE /Fformat /Imm-dd-YY   /A06-06-66   /Ozm/zd/ccyy
  715. FDATE /Fformat /Imm-dd-YY   /A6-06-66    /Ozm/zd/ccyy
  716. FDATE /Fformat /Imm-dd-YY   /A06-6-66    /Ozm/zd/ccyy
  717. FDATE /Fformat /Imm-dd-YY   /A6-6-66     /Ozm/zd/ccyy
  718. @PAUSE
  719.  
  720. CLS
  721. @set date1=
  722. @echo TEST FDATE WITH ENVIRONMENT MANIPULATION PROGRAMS
  723. @echo reformat a date; use STRINGS to put it into DATE1 environment variable
  724. FDATE /Fformat /A06-09-48 /Imm-dd-yy /O"mn zd, ccyy"|STRINGS date1= ASK >NUL
  725. @echo DATE1 environment variable is %DATE1%
  726. @echo.
  727. @set date1=
  728. @echo reformat a date; use GET to put it into DATE1 environment variable
  729. FDATE /Fformat /A06-09-48 /Imm-dd-yy /O"mn zd, ccyy"|GET ZE /Vdate1 >NUL
  730. @echo DATE1 environment variable is %DATE1%
  731. @echo.
  732. @set date1=
  733. @echo reformat a date; use GET to put it into DATE1 environment variable
  734. FDATE /Fformat /Atoday  /Oyymmdd|GET ZE /Vdate1 >NUL
  735. @echo DATE1 environment variable is %DATE1%
  736. @echo.
  737. @set date1=
  738. @echo reformat a date; use GET to put it into DATE1 environment variable
  739. FDATE /Fformat /Atoday  /Occyymmdd|GET ZE /Vdate1 >NUL
  740. @echo DATE1 environment variable is %DATE1%
  741. @PAUSE
  742.  
  743.  
  744. CLS
  745. @ECHO LAST  DAY OF YEAR 9999
  746. FDATE /Fformat /A99991231 /iccyymmdd /Oday#
  747. @ECHO.
  748. @ECHO LAST  DAY OF YEAR 2099
  749. FDATE /Fformat /A20991231 /iccyymmdd /Oday#
  750. @ECHO.
  751. @ECHO FIRST DAY OF YEAR 0001
  752. FDATE /Fformat /A00010101 /iccyymmdd /Oday#
  753. @ECHO.
  754. @ECHO FIRST DAY OF YEAR 1900
  755. FDATE /Fformat /A19000101 /iccyymmdd /Oday#
  756. @ECHO.
  757. @ECHO FIRST DAY OF YEAR 1990
  758. FDATE /Fformat /A19900101 /iccyymmdd /Oday#
  759. @PAUSE
  760.  
  761. CLS
  762. @echo TEST "JULIAN" OUTPUT FORMATS
  763. FDATE /Fformat /Atoday               /Ojuldate
  764. FDATE /Fformat /Atoday               /Oday#
  765. FDATE /Fformat /Atoday               /Ominute#
  766. FDATE /Fformat /Atoday               /Osecond#
  767. FDATE /Fformat /A19950101 /Iccyymmdd /Ominute#
  768. FDATE /Fformat /A19950101 /Iccyymmdd /Osecond#
  769. @PAUSE
  770.  
  771. CLS
  772. @ECHO OFF
  773. @ECHO CALCULATE HOW LONG IT TOOK TO RUN A PROGRAM, IN SECONDS
  774.  
  775. REM  GET PROGRAM BEGIN TIME, IN MINUTES
  776. @set BegM=
  777. @set EndM=
  778. @set RunM=
  779. FDATE /Fformat /Atoday /Ominute# /P"SET BegM=" >JUNKDATE.BAT
  780. CALL junkdate.bat
  781.  
  782. REM  GET PROGRAM BEGIN TIME, IN SECONDS
  783. @set BegS=
  784. @set EndS=
  785. @set RunS=
  786. FDATE /Fformat /Atoday /Osecond# /P"SET BegS=" >JUNKDATE.BAT
  787. CALL junkdate.bat
  788.  
  789. rem ===============================================================
  790. rem [simulate execution of a program: loop for a minute or less]
  791. rem [In a real batch file, you would put your program statements here]
  792. rem ===============================================================
  793. :BegLoop
  794.    FDATE /Fformat /Atoday /Osecond# /P"SET EndS=" >JUNKDATE.BAT
  795.    CALL JUNKDATE.BAT
  796.    FDATE /Fformat /Atoday /Ominute# /P"SET EndM=" >JUNKDATE.BAT
  797.    CALL JUNKDATE.BAT
  798.  
  799.    rem  calculate run time (difference between start time and end time)
  800.    FDATE /F#dif /A%EndM% /B%BegM% /P"SET RunM=" > JUNKDATE.BAT
  801.    CALL JUNKDATE.BAT
  802.  
  803.    rem  calculate run time (difference between start time and end time)
  804.    FDATE /F#dif /A%EndS% /B%BegS% /P"SET RunS=" > JUNKDATE.BAT
  805.    CALL JUNKDATE.BAT
  806.    echo Elapsed time:  %RunS% second(s)
  807.  
  808.    if (%RunM%)==()  goto EndLoop
  809.    if (%RunM%)==(0) goto BegLoop
  810. :EndLoop
  811. rem ===============================================================
  812.  
  813. REM  GET PROGRAM END TIME IN MINUTES
  814. FDATE /Fformat /Atoday /Ominute#  /P"SET EndM=" > JUNKDATE.BAT
  815. CALL JUNKDATE.BAT
  816. echo TEST----   program end   time (Julian minutes): %EndM%
  817. echo TEST----   program begin time (Julian minutes): %BegM%
  818.  
  819. rem  calculate run time (difference between start time and end time)
  820. FDATE /F#dif /A%EndM% /B%BegM% /P"SET RunM=" > JUNKDATE.BAT
  821. CALL JUNKDATE.BAT
  822. DEL  JUNKDATE.BAT
  823.  
  824. echo Program ran for %RunM% minute(s)
  825. @set BegM=
  826. @set EndM=
  827. @set RunM=
  828.  
  829. echo.
  830. REM  GET PROGRAM END TIME IN SECONDS
  831. FDATE /Fformat /Atoday /Osecond#  /P"SET EndS=" > JUNKDATE.BAT
  832. CALL JUNKDATE.BAT
  833. DEL  JUNKDATE.BAT
  834. echo TEST----   program end   time (Julian seconds): %EndS%
  835. echo TEST----   program begin time (Julian seconds): %BegS%
  836.  
  837. rem  calculate run time (difference between start time and end time)
  838. FDATE /F#dif /A%EndS% /B%BegS% /P"SET RunS=" > JUNKDATE.BAT
  839. CALL JUNKDATE.BAT
  840. DEL  JUNKDATE.BAT
  841.  
  842. echo Program ran for %RunS% second(s)
  843. @set BegS=
  844. @set EndS=
  845. @set RunS=
  846. @PAUSE
  847.  
  848. @echo off
  849. CLS
  850. @echo END OF FDATE TEST BATCH FILE
  851. :ENDIT
  852.